﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_Iask_query_answer_CX_Iask_Answer : System.Web.UI.Page
{
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    public string RedirID = "";

    /// <summary>
    /// 删除事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
       
        try
        {
            RedirID = Request.QueryString["id"].ToString();
            if (RedirID != "")
            {
                if (!IsPostBack)
                {
                    //得到
                    try
                    {
                        MyDt = TextData.SqlataSet("select * from  [ask_query] where ask_query_id = " + RedirID).Tables[0];

                        querystion.DataSource = MyDt;
                        querystion.DataBind();

                        MyDt = TextData.SqlataSet("select * from   [ask_answer] where ask_query_id = " + RedirID).Tables[0];
                        Answer.DataSource = MyDt;
                        Answer.DataBind();




                    }
                    catch
                    {

                    }
                }
            }


        }
        catch
        {

        }

    }




    /// <summary>
    /// 删除事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void delcc(object sender, EventArgs e)
    {

        string CID = ((LinkButton)sender).CommandArgument.ToString();
        if (CID != "")
        {
            try
            {
                TextData.SqlDataSave("delete  [ask_query] where ask_query_id =  " + CID);
                TextData.SqlDataSave("delete  [ask_answer] where ask_query_id =  " + CID);//删除所有问答

                tt.Text = "";
                tt.Text = "<script>alert('删除 信息成功');window.close();</script>";

            }
            catch
            {
                tt.Text = "";
                tt.Text = "删除  时出现错误　操作没有完成 ";
            }
        }

    }


    /// <summary>
    /// 删除事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void delccanswer(object sender, EventArgs e)
    {

        string CID = ((LinkButton)sender).CommandArgument.ToString();
        if (CID != "")
        {
            try
            {
                TextData.SqlDataSave("delete  [ask_answer] where ask_answer_id  =  " + CID);


                tt.Text = "";
                tt.Text = "<script>alert('删除 信息成功');</script>";

                MyDt = TextData.SqlataSet("select * from   [ask_answer] where ask_query_id = " + RedirID).Tables[0];
                Answer.DataSource = MyDt;
                Answer.DataBind();

            }
            catch
            {
                tt.Text = "";
                tt.Text = "删除  时出现错误　操作没有完成 ";
            }
        }

    }

    /// <summary>
    /// 删除提示
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void querystion_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            LinkButton MyLb = ((LinkButton)e.Item.FindControl("LinkButton1"));
            MyLb.Attributes.Add("onclick", "return confirm('您确定要删除吗');");
        }
    }


    //
    /// <summary>
    /// 删除提示 下面的回答
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Answer_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            LinkButton MyLb = ((LinkButton)e.Item.FindControl("LinkButton33"));
            MyLb.Attributes.Add("onclick", "return confirm('您确定要删除吗');");
        }
    }



}
